﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace ReporterEngine
{

    public partial class sQuery
    {
        public sQuery types(string typeNames)
        {
            var result = sQuery.New(_model);

            //add elements of type

            var typeList = CIFModel.NormalizeNamesList(typeNames);

            foreach (var typeName in typeList)
            {
                var clearName = typeName.ToLower();

                var modelType = _model.ModelTypes.Where(x => x.Label.ToLower() == clearName || x.PluralLabel.ToLower() == clearName).FirstOrDefault();

                if (modelType != null)
                {
                    result.Elements.AddRange(modelType.Nodes);
                }
            }

            return result;
        }
    }
}
